{{ 'section-main-product.css' | asset_url | stylesheet_tag }}
<style>
  .bvb-content {
    cursor: pointer;
  }
  @media screen and (max-width: 1200px) and (min-width: 900px) {
    .bvb-banner .bvb-content .text {
      top: 30px;
    }
    .bvb-banner .mySwiper-block .text_1 svg {
      height: 18px;
    }
    .bvb-banner .mySwiper-block .text_2 {
      font-size: 30px;
      line-height: 36px;
    }
  }
  
  @media screen and (min-width: 900px) and (max-height: 700px) {
    .bvb-banner .bvb-content .text {
      top: 15px;
    }
  }
  
  @media screen and (min-width: 750px) and (max-width: 900px) {
    .bvb-content .bvb-bottom {
      bottom: 50px;
    }
  }
  @media screen and (max-width: 750px) {
    .bvb-banner .bvb-content .text {
      top: 20px;
    }
    
    .bvb-banner .mySwiper-block .text_1 svg {
      height: 12px;
    }
  }
  .bvb-banner .product-expore-more{
    padding: 15px 24px;
    font-size: 14px;
    line-height: 22px;
  }
  .product-expore-more svg{
    display: none;
  }
  @media screen and (max-width: 990px){
  .tenways-bvb-banner .button_label .product-expore-more{
    background: transparent;
    color: #fff;
    margin: 0;
  } 
  .tenways-bvb-banner .button_label .product-expore-more svg{
    display: block;
    margin: 0;
    margin-left: 8px;
   }
  }
</style>
<div class="bvb-banner tenways-bvb-banner" id="tenways_bvb">
    <div class="swiper mySwiper-block">
       <div class="swiper-wrapper">
        {%- for block in section.blocks -%}
          <div class="{% if block.settings.no_video %} button_label {% endif %} swiper-slide swiper-slide_{{ forloop.index0 }}" data-swiper-parallax="-600">
            <div class="bvb-content">
              {% if block.settings.text_1 !=blank %}
                <div class="text">
                  <div class="text_1">{{ block.settings.text_1 }}</div>
                  {% if block.settings.text_1 !=blank %}
                  <div class="text_2">{{ block.settings.text_2 }}</div>
                  {% endif %}
                  {% if block.settings.text_3 !=blank %}
                  <div class="text_3">{{ block.settings.text_3 }}</div>
                  {% endif %}
                </div>
              {% endif %}
              <div class="bvb-top">
                {%- if block.settings.button_link != blank -%}
              <a{% if block.settings.button_link != blank %} href="{{ block.settings.button_link }}"{% endif %} class="no-underline"{% if block.settings.button_link == blank %} aria-disabled="true"{% endif %}>
            {% endif %}
                <div class="pc_banner image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                    {% if block.settings.height == 'adapt' and block.settings.image != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image.aspect_ratio | times: 100 }}%;"{% endif %}
                    >
                    {%- if block.settings.image != blank -%}
                    <img
                        srcset="{%- if block.settings.image.width >= 375 -%}{{ block.settings.image | img_url: '375x' }} 375w,{%- endif -%}
                        {%- if block.settings.image.width >= 750 -%}{{ block.settings.image | img_url: '750x' }} 750w,{%- endif -%}
                        {%- if block.settings.image.width >= 1400 -%}{{ block.settings.image | img_url: '1500x' }} 1500w,{%- endif -%}
                        {%- if block.settings.image.width >= 1500 -%}{{ block.settings.image | img_url: '1500x' }} 1500w,{%- endif -%}
                        {%- if block.settings.image.width >= 1780 -%}{{ block.settings.image | img_url: '1780x' }} 1780w,{%- endif -%}
                        {%- if block.settings.image.width >= 2000 -%}{{ block.settings.image | img_url: '2000x' }} 2000w,{%- endif -%}
                        {%- if block.settings.image.width >= 3000 -%}{{ block.settings.image | img_url: '3000x' }} 3000w,{%- endif -%}
                        {%- if block.settings.image.width >= 3840 -%}{{ block.settings.image | img_url: '3840x' }} 3840w,{%- endif -%}"
                        data-src="{{ block.settings.image | img_url: '1500x' }}"
                        alt="{{ block.settings.image.alt | escape }}"
                        loading="lazy"
                        class="lazyload"
                        width="{{ block.settings.image.width }}"
                        height="{{ block.settings.image.height }}"
                    >
                    {%- else -%}
                    {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                    {%- endif -%}
                </div>
                <div class="image_mobile image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image_mobile != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                    {% if block.settings.height == 'adapt' and block.settings.image_mobile != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image_mobile.aspect_ratio | times: 100 }}%;"{% endif %}
                    >
                    {%- if block.settings.image_mobile != blank -%}
                    <img
                    srcset="{%- if block.settings.image_mobile.width >= 375 -%}{{ block.settings.image_mobile | img_url: '375x' }} 375w,{%- endif -%}
                    {%- if block.settings.image_mobile.width >= 412 -%}{{ block.settings.image_mobile | img_url: '412x' }} 412w,{%- endif -%}
                    {%- if block.settings.image_mobile.width >= 750 -%}{{ block.settings.image_mobile | img_url: '750x' }} 750w,{%- endif -%}
                    {%- if block.settings.image_mobile.width >= 1100 -%}{{ block.settings.image_mobile | img_url: '1100x' }} 1100w,{%- endif -%}
                    {%- if block.settings.image_mobile.width >= 1500 -%}{{ block.settings.image_mobile | img_url: '1500x' }} 1500w,{%- endif -%}
                    {%- if block.settings.image_mobile.width >= 1780 -%}{{ block.settings.image_mobile | img_url: '1780x' }} 1780w,{%- endif -%}
                    {%- if block.settings.image_mobile.width >= 1903 -%}{{ block.settings.image_mobile | img_url: '1903x' }} 1903w,{%- endif -%}
                    {{ block.settings.image_mobile | img_url: 'master' }} {{ block.settings.image_mobile.width }}w"
                    sizes="{% if block.settings.image_2 != blank and block.settings.stack_images_on_mobile %}(min-width: 750px) 50vw, 100vw{% elsif block.settings.image_2 != blank %}50vw{% else %}100vw{% endif %}"
                    src="{{ block.settings.image_mobile | img_url: '1500x' }}"
                    loading="lazy"
                    alt="{{ block.settings.image_mobile.alt | escape }}"
                    width="{{ block.settings.image_mobile.width }}"
                    height="{{ block.settings.image_mobile.width | divided_by: block.settings.image_mobile.aspect_ratio }}"
                    >
                    {%- else -%}
                    {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                    {%- endif -%}
                </div>
                {%- if block.settings.button_link != blank -%}
                </a>
                {% endif %}
              </div>
              <div class="bvb-bottom tenways-bvb-block-bttom">
                <div class="page-width">
                  {%- if block.settings.button_label != blank -%}
                <a{% if block.settings.button_link != blank %} href="{{ block.settings.button_link }}"{% endif %} class="explore-more tenways-hover button{% if block.settings.button_style_secondary %} button--secondary{% else %} button--primary{% endif %}"{% if block.settings.button_link == blank %} aria-disabled="true"{% endif %} {{ block.shopify_attributes }}>
                {{ block.settings.button_label | escape }}
               </a>
                {%- endif -%}  
                {% if block.settings.button_label_1 != blank %}
                <modal-opener class="twy-button product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-{{ block.id }}" >
                  <button id="ProductPopup-{{ block.id }}" class="product-popup-modal__button link product-bvb-video" type="button" aria-haspopup="dialog">
                    {{ block.settings.button_label_1 | escape }} {% render 'icon-explore' %}
                  </button>
                </modal-opener>
                {% endif %}  
                {%- if block.settings.button_label3 != blank -%}
                  <a{% if block.settings.button_link3 != blank %} href="{{ block.settings.button_link3 }}"{% endif %} class="button link product-popup-modal__button product-expore-more {% if block.settings.button_style_secondary %} button--secondary{% else %} button--primary{% endif %}"{% if block.settings.button_link3 == blank %} aria-disabled="true"{% endif %} >
                  {{ block.settings.button_label3 | escape }} {% render 'icon-explore' %}
                </a>
              {%- endif -%}  
                </div>  
              </div>
           </div>
           {% unless block.settings.no_video %}
            <modal-dialog id="PopupModal-{{ block.id }}" class="product-popup-modal">
              <div role="dialog" aria-label="{{ block.settings.button_label_1 }}" aria-modal="true" class="product-popup-modal__content" >
                <div class="con_popup">
          
                <video loop controls playsinline poster="https://cdn.shopify.com/s/files/1/0563/3926/7733/files/bvbbg.jpg?v=1678860336">
                <source src="https://cdn.shopify.com/videos/c/o/v/196e8491d36d4b988aa4fe1c0ed6a1cc.mp4" type="video/mp4">
                <source src="https://cdn.shopify.com/videos/c/o/v/196e8491d36d4b988aa4fe1c0ed6a1cc.ogg" type="video/ogg">
              </video> 
          
                
                </div>
                <button id="ModalClose-{{ block.id }}" type="button" class="product-popup-modal__toggle" aria-label="{{ 'accessibility.close' | t }}">{% render 'pop-close' %}</button>
              </div>
            </modal-dialog> 
           {% endunless %} 
          </div>
        {%- endfor -%} 
       </div>
       <div class="swiper-pagination pagination_bvb"></div>
    </div>
</div>

<script>
  var swiperNode = new Swiper(".mySwiper-block", {
    speed: 600,
    slidesPerView: 1,
    autoplay: {
      delay: 6000,
      disableOnInteraction: false
    },
    effect: 'fade',
    pagination: {
      el: ".swiper-pagination.pagination_bvb",
      clickable: true,
      renderBullet: function (index, className) {
        return '<span class="' + className + '"><span class="cursor"></span></span>';
      },
    },
  });
  
  $('.product-popup-modal__toggle').click(function(){
    if (typeof swiperNode!== "undefined") {
      swiperNode.autoplay.start();
    }
  })
  $('.product-bvb-video').click(function(){
    swiperNode.autoplay.stop();
  })
  
  $(".bvb-content").on('click', function (event) {
    if (event.target.type !== 'button') {
      location.href = $(this).find('.explore-more').attr('href');
    }
  });
  
  $(document).on('click', function (event) {
    if(event.target.closest(".tenways-bvb-banner") === null){
      document.body.classList.remove('overflow-hidden');
      $('.product-popup-modal').removeAttr('open');
    }
  })
</script>

{% schema %}
    {
      "name": "Tenways BVB block",
      "class": "bvb-video spaced-block spaced-block--full-width",
      "blocks": [
        {
        "type": "block",
        "name": "block",
        "settings": [
          {
            "type": "checkbox",
            "id": "no_video",
            "label": "No video",
            "default": false
          },
          {
            "type": "html",
            "id": "text_1",
            "label": "text 1"
          },
          {
            "type": "text",
            "id": "text_2",
            "label": "text 2"
          },
          {
            "type": "text",
            "id": "text_3",
            "label": "text 3"
          },
          {
            "type": "image_picker",
            "id": "image",
            "label": "image"
          },
            {
            "type": "image_picker",
            "id": "image_mobile",
            "label": "Image mobile"
            },
            {
              "type": "select",
              "id": "height",
              "options": [
                {
                  "value": "adapt",
                  "label": "adapt"
                },
                {
                  "value": "small",
                  "label": "small"
                },
                {
                  "value": "large",
                  "label": "large"
                }
              ],
              "default": "adapt",
              "label": "adapt"
            },
            {
            "type": "text",
            "id": "button_label",
            "default": "Button label",
            "label": "Button label",
            "info": "Button label"
            },
            {
            "type": "url",
            "id": "button_link",
            "label": "button_link"
            },
            {
            "type": "text",
            "id": "button_label_1",
            "default": "Button label",
            "label": "Button label",
            "info": "Button label"
            },
            {
            "type": "text",
            "id": "button_label3",
            "label": "Button label3",
            "info": "Button label3"
            },
            {
            "type": "url",
            "id": "button_link3",
            "label": "button_link3"
            },
            {
              "type": "text",
              "id": "price_finland",
              "label": "Price Finland"
            },
            {
              "type": "text",
              "id": "price_denmark",
              "label": "Price Denmark"
            },
            {
              "type": "text",
              "id": "price_sweden",
              "label": "Price Sweden"
            },
            {
              "type": "text",
              "id": "price_swland",
              "label": "Price Switzerland"
            },
            {
              "type": "text",
              "id": "price_norway",
              "label": "Price Norway"
            },
            {
              "type": "text",
              "id": "price_us",
              "label": "Price US"
            },
            {
              "type": "text",
              "id": "price_other",
              "label": "Price Other"
            }
        ]
        }
      ],
      "presets": [
        {
            "name": "Tenways BVB block"
        }
      ]
    }
      {% endschema %}